%%%-------------------------------------------------------------------
%% @doc cache_test public API
%% @end
%%%-------------------------------------------------------------------

-module(cache_test).

-include_lib("eunit/include/eunit.hrl").

-export([run/0]).

run() ->
    ?debugMsg("cache test begin."),
    {ok, _} = application:ensure_all_started(cache),

    DCS = [DC:start() || DC <- [dc_test1, dc_test2]],
    ?debugFmt("start dc: ~p", [DCS]),
    TD1 = dc_test1:load(1021),
    TD2 = dc_test2:load(1022),
    ?debugFmt("dc_test1 load: ~p", [TD1]),
    ?debugFmt("dc_test2 load: ~p", [TD2]),
    ?debugFmt("dc_test1 save: ~p", [dc_test1:save(TD1)]),
    ?debugFmt("dc_test2 save: ~p", [dc_test2:save(TD2)]),
    timer:sleep(1000),
    ?debugFmt("dc_test1 ets: ~p", [ets:tab2list(dc_test1)]),
    ?debugFmt("dc_test2 ets: ~p", [ets:tab2list(dc_test2)]),
    ?debugFmt("dc_test1 delete: ~p", [dc_test1:delete(1021)]),
    timer:sleep(10000),
    ?debugFmt("dc_test2 save: ~p", [dc_test2:save(TD2)]),
    timer:sleep(1000),
    ?debugFmt("dc_test1 ets: ~p", [ets:tab2list(dc_test1)]),
    ?debugFmt("dc_test2 ets: ~p", [ets:tab2list(dc_test2)]),
    application:stop(cache),
    ?debugMsg("cache test end."),
    ok.

%% internal functions


